<template>
  <div class="home">
    <div class="model-wrapper">
      <ht-matrix :data="jsonData" :mapping="mapping" @dbclick="handleClickDevice" />
    </div>
  </div>
</template>

<script>
import mapping from '@utils/mapping';
import jsonData from '@utils/json';
import HtMatrix from '@components/ht-matrix/ht-matrix';

export default {
  name: 'Home',
  components: { HtMatrix },
  mounted() {},
  data() {
    return {
      mapping,
      jsonData,
    };
  },
  methods: {
    handleClickDevice(data) {
      console.log(data);
      const { jsonData } = this;
      this.jsonData = jsonData.map(item => {
        if (item.machineId === data.machineId) {
          item.list = item.list.map(item => ({ key: item.key, value: item.value }));
          return item;
        } else {
          return item;
        }
      });
    },
  },
};
</script>

<style>
.home {
  display: flex;
  height: 100%;
  justify-content: center;
  align-items: center;
}
.model-wrapper {
  width: 100%;
  height: 100%;
}
</style>
